package operation;

import book.Book;
import book.BookList;
import book.ListNode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-09-08
 * Time: 11:05
 */
public class ReturnOperation implements IOperation{
    public void work(BookList bookList) {
        System.out.println("归还图书");
        System.out.println("请输入您要归还的图书名：");
        String bookName = scanner.nextLine();
        ListNode cur = bookList.getHead();
        while (cur != null){
            Book book = cur.val;
            if (bookName.equals(cur.val.getName())){
                book.setBorrowed(false);
                System.out.println("归还成功");
                System.out.println(book);
                return;
            }
            cur = cur.next;
        }
        System.out.println("归还信息不存在，如果您想为图书馆尽一份力，请联系管理员ljk & msr");
    }
}
